package com.yfp.group.controller;

import com.yfp.common.core.domain.R;
import com.yfp.common.core.web.controller.BaseController;
import com.yfp.common.core.web.page.TableDataInfo;
import com.yfp.group.domain.EnterpriseOrderCoupon;
import com.yfp.group.domain.EnterpriseOrderCouponInfo;
import com.yfp.group.service.EnterpriseOrderCouponService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description: 企业券码管理
 * 
 * @CreateDate: 2024/8/15 14:09
 * @UpdateUser: 
 * @UpdateDate: 2024/8/15 14:09
 * @UpdateRemark: 暂无修改
 * @Version: 1.0
 */
@RestController
@RequestMapping("/enterpriseOrderCoupon")
@Tag(name = "企业券码管理")
public class EnterpriseOrderCouponController extends BaseController {

    @Resource
    private EnterpriseOrderCouponService enterpriseOrderCouponService;

    @GetMapping("/list")
    @Operation(summary = "企业券码列表")
    @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Successful response", content = @Content(mediaType = "application/json", schema = @Schema(implementation = EnterpriseOrderCoupon.class)))})
    public R<TableDataInfo> list(EnterpriseOrderCoupon enterpriseOrderCoupon) {
        startPage();
        List<EnterpriseOrderCoupon> list = enterpriseOrderCouponService.findEnterpriseOrderCoupon(enterpriseOrderCoupon);
        TableDataInfo dataTable = getDataTable(list);
        return R.ok(dataTable);
    }

    @GetMapping("/orderCouponInfo")
    @Operation(summary = "企业券码详情")
    @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Successful response", content = @Content(mediaType = "application/json", schema = @Schema(implementation = EnterpriseOrderCouponInfo.class)))})
    public R<TableDataInfo> orderCouponInfo(EnterpriseOrderCouponInfo enterpriseOrderCouponInfo) {
        startPage();
        List<EnterpriseOrderCouponInfo> list = enterpriseOrderCouponService.findEnterpriseOrderCouponInfo(enterpriseOrderCouponInfo);
        TableDataInfo dataTable = getDataTable(list);
        // 数据补全
        List<EnterpriseOrderCouponInfo> infoList = enterpriseOrderCouponService.orderCouponInfoComplement(list);
        dataTable.setRows(infoList);
        return R.ok(dataTable);
    }
}